package com.meetingshow.commu.dao;

import java.util.List;

import com.meetingshow.common.base.dao.BaseDAO;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.commu.dao.model.QuestionPO;

public class QuestionDAO extends BaseDAO {
    public Integer saveQuestion(QuestionPO questionPO) throws Exception {
        return (Integer) this.saveBaseObj(questionPO);
    }

    public void updateQuestion(QuestionPO questionPO) throws Exception {
        this.updateBaseObj(questionPO);
    }

    public void removeQuestion(QuestionPO questionPO) throws Exception {
        this.deleteBaseObj(questionPO);
    }
    
    public QuestionPO loadQuestionById(Integer questionId) throws Exception {
        return this.queryById(QuestionPO.class, questionId);
    }

    public QueryResults<QuestionPO> queryQuestion(QueryStruct queryStruct) throws Exception {
        QueryResults<QuestionPO> queryResults = new QueryResults<QuestionPO>();
        List<QuestionPO> resultList = findByParameter(queryStruct);
        queryResults.setResultList(resultList);
        if (queryStruct.getFirstResultNo() != null
                && queryStruct.getResultsPerGroup() != null) {
            queryResults = queryPageInfo(queryStruct, queryResults);
        } else {
            queryResults.setTotalResultsNum(Long.valueOf(resultList.size()));
        }
        return queryResults;
    }
}
